﻿using System.ComponentModel;

namespace YanZhiwei.DotNet2.Utilities.Base
{
    /// <summary>
    /// 向客户端发出某一属性值已更改的通知。 
    /// </summary>
    public class NotifyPropertyChanged : INotifyPropertyChanged
    {
        /* eg:
            set
            {
                if (value != _name)
                {
                    _name = value;
                    NotifyChanged(Name);
                }
            }
         */
        #region 向客户端发出某一属性值已更改的通知
        /// <summary>
        /// 向客户端发出某一属性值已更改的通知事件
        /// </summary>
        public event PropertyChangedEventHandler PropertyChanged;
        /// <summary>
        /// 需要向客户端通知的属性名称
        /// </summary>
        /// <param name="propertyName">属性名称</param>
        public void NotifyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion
    }
}
